﻿/*include:js\declare*/
//鼠标拖拽	<div body="true" floatcenter="true" id="YYY" style="display:none"><div mousemove="{MoveId:'YYY'}" id="XXX"></div></div>
(function(){
var MouseMove=function()
	{
	this.GetArgument(arguments[0],{Id:null,Event:null,MoveId:null},1);
	this.MoveEvent=fastCSharp.ThisEvent(this,this.Move);
	this.StopEvent=fastCSharp.ThisFunction(this,this.Stop);
	this.Start(this.Event||{IsGetOnly:1});
	};
(fastCSharp.Functions.MouseMove=MouseMove).Inherit(fastCSharp.BaseFunction,{
Start:function(Event)
	{
	if(!Event.IsGetOnly)
		{
		if(this.IsStart)	this.Stop();
		var Element=fastCSharp.$Id(this.Id),Input=Element.Element();
		if(Input!=this.Element)
			{
			this.Element=Input;
			fastCSharp.$(document.body).AddEvent('mousedown,mouseup,blur',this.StopEvent).AddEvent('mousemove',this.MoveEvent);
			}
		var Element=fastCSharp.$Id(this.MoveId).Css('position','absolute');
		this.Left=Element.Left();
		this.Top=Element.Top();
		this.ClientX=Event.clientX;
		this.ClientY=Event.clientY;
		this.IsStart=1;
		}
	},
//Close:function()
//	{
//	this.Element.Set('mousemove',null);
//	this.Element=null;
//	},
Move:function(Event)
	{
	fastCSharp.$Id(this.MoveId).Left(this.Left+Event.clientX-this.ClientX).Top(this.Top+Event.clientY-this.ClientY);
	},
Stop:function()
	{
	if(this.IsStart)
		{
		fastCSharp.$(document.body).DeleteEvent('mousedown,mouseup,blur',this.StopEvent).DeleteEvent('mousemove',this.MoveEvent);
		this.IsStart=0;
		}
	}
		});
new fastCSharp.Declare('MouseMove','mousedown','AttributeName');
})();